
package botlab;

import botlab.Game;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
import java.awt.Canvas;

/**
 *  Singleton pattern.
 * @author Quentin
 */
public class GameManager
{
    private static final GameManager instance = new GameManager();
    private Game game;
    private Canvas canvas;
    private JmeCanvasContext context;
    
    public static GameManager getInstance()
    {
        return instance;
    }
    
    public GameManager()
    {
        createNewCanvas();
    }
    
    public Game getGame()
    {
        return game;
    }

    public Canvas getCanvas()
    {
        return canvas;
    }
    
    public void createNewCanvas()
    {
        AppSettings settings = new AppSettings(true);
        settings.setWidth(640);
        settings.setHeight(480);
        settings.setTitle("Botlab");
        settings.setFrameRate(60);

        game = new Game();
        Game.setApp(game);
        game.setPauseOnLostFocus(false);
        game.setSettings(settings);
        game.createCanvas();

        context = (JmeCanvasContext) game.getContext();
        canvas = context.getCanvas();
        canvas.setSize(settings.getWidth(), settings.getHeight());
    }

    public JmeCanvasContext getContext()
    {
        return context;
    }
}
